<?php

require_once('..'. DIRECTORY_SEPARATOR . 'bootstrap.php');

$env = Bike_Service_Locator::getService('Environment');

ob_start();
header('Content-Type: text/html; charset=UTF-8');
header('Last-Modified: '.str_replace('+0000', 'GMT', gmdate('r')));
try{
	echo $env->handleRequest();
}catch(Exception $e){
	switch($e->getCode()){
		case Bike_Environment_Exception::ACCESS_DENIED:
			$parser = Bike_Service_Locator::getService('Parser_bo');
			$parser->setTemplate('Bike/login.tpl');
			echo $parser->processTemplate();
			break;
		case Bike_Environment_Exception::PAGE_NOT_FOUND:
			header('HTTP/1.1 404 Not Found');
			break;
		default:
			break;
	}
}
ob_end_flush();